<template>
	<div class="personal">
		<top title="个人中心"></top>
		<div class="personal-head">
			<div style="padding: 0px 35px 0px 35px;box-sizing: border-box;">
				<div class="blue">
					<div class="blue-left">
						<p>猫票ID</p>
						<p>{{data.cat_ticket_id}}</p>
					</div>
					<div class="blue-right">
						<img class="news" src="../static/img/news.png" />
					</div>
				</div>
			</div>
			<div class="head-content">
				<div class="personal-info" @click="regist">
					<img :src="data.head_portrait" />
					<p>{{data.nick_name}}</p>
				</div>
				<!--  -->
				<div class="personal-cla">
					<div class="personal-cla-con">
						<img class="cat" src="../static/img/cat_beans.png" />
						<p>我的猫豆</p>
					</div>
					<div class="personal-cla-con">
						<img class="ku" src="../static/img/gift_room.png" />
						<p>礼品库房</p>
					</div>
				</div>
			</div>
		</div>
		<!--  -->
		<div class="personal-list">
			<ul>
				<li class="list-one">
					<div class="list-title">
						<img src="../static/img/fllow.png" />
						<p>我关注的</p>
					</div>
					<div class="img-list my_concern">
						<img v-for="(item,index) in data.my_concern" class="list-head" :src="item.head_portrait" />
					</div>
				</li>
				<li class="list-flex">
					<div class="list-title">
						<img src="../static/img/fllow.png" />
						<p>我关注的</p>
					</div>
					<div class="img-list">
						<img class="right-list" src="../static/img/right.png" />
					</div>
				</li>
				<li class="list-flex">
					<div class="list-title">
						<img src="../static/img/fllow.png" />
						<p>我关注的</p>
					</div>
					<div class="img-list">
						<img class="right-list" src="../static/img/right.png" />
					</div>
				</li>
			</ul>
		</div>
		<!--  -->
		<tabbar></tabbar>
	</div>
</template>

<script>
	import top from '@/components/top.vue';
	import tabbar from '@/components/tabbar.vue';
	import modal from '../routeUrl.js';
	import globaldata from '../globaldata.js';
	import USER_CACHE from '../cache.js';
	export default {
		components: {
			top,
			tabbar
		},
		data() {
			return {
				data: {}
			}
		},
		created() {
			window.addEventListener('beforeunload', e => this.beforeunloadFn(e));
			console.log(USER_CACHE.get('personal'))
			if (USER_CACHE.get('personal')) {

				this.data = USER_CACHE.get('personal');

			} else {
				this.personal()
			}

		},
		destroyed() {
			window.removeEventListener('beforeunload', e => this.beforeunloadFn(e))
		},
		methods: {
			regist() {
				this.$router.push({
					name: 'regist'
				})
			},
			personal() {
				modal.myInfo(globaldata.t_id).then(res => {
					if (res.code == 1) {
						console.log(res)
						
						USER_CACHE.set('personal', res.data);
					} else {
						alert('获取失败')
					}

				})
			},
			beforeunloadFn(e) {
				console.log('刷新或关闭');
				USER_CACHE.removestorage('personal');

			}
		}
	}
</script>

<style lang="scss">
	@import '../assets/scss/main.scss';

	.list-flex {
		display: flex;
		display: -webkit-flex;
		justify-content: space-between;
		align-items: center;
	}


	.right-list {
		width: px2vw(6);
		height: px2vw(10);
		display: block;
	}

	.my_concern {
		display: flex;
		display: -webkit-flex;
		align-items: center;
	}

	.my_concern img {
		margin-right: px2vw(10);
	}

	.cat {
		width: px2vw(16);
		height: px2vw(17);
		display: block;
	}

	.ku {
		width: px2vw(17);
		height: px2vw(15);
		display: block;
	}

	.list-title img {
		width: px2vw(21);
		height: px2vw(19);
		display: block;
	}

	.img-list {
		padding-left: px2vw(7);
		margin-top: px2vw(8);
	}

	.list-head {
		width: px2vw(35);
		height: px2vw(35);
		display: block;
		border-radius: 50%;
	}

	.personal-list {
		padding: 0px px2vw(20);
		box-sizing: border-box;
		background: #FFFFFF;
		margin-top: px2vw(6);
	}

	.personal-list ul li {
		padding-top: px2vw(20);
		padding-bottom: px2vw(10);
		border-bottom: 1px solid #E8EBF1;
	}

	.list-title {
		display: flex;
		display: -webkit-flex;
		align-items: center;
	}

	.list-title p {
		margin-left: px2vw(9);
		font-size: px2vw(15);
	}

	body {
		background: #F6F6F6;
	}

	.blue {
		width: 100%;
		height: px2vw(70);
		background: #71CAC9;
		border-top-left-radius: px2vw(15);
		border-top-right-radius: px2vw(15);
		display: flex;
		display: -webkit-flex;
		justify-content: space-between;
		padding: px2vw(15) px2vw(30) 0 px2vw(17);
		box-sizing: border-box;
	}

	.news {
		width: px2vw(17);
		height: px2vw(20);
		display: block;
	}

	.blue-left p:first-child {
		font-size: px2vw(15);
		color: #FFFFFF;
	}

	.blue-left p:last-child {
		font-size: px2vw(11);
		color: #FFFFFF;
	}

	.head-content {
		width: 100%;
		height: px2vw(150);
		background: #FFFFFF;
		position: relative;
	}

	.personal-info {
		width: 100%;
		position: absolute;
		left: 0px;
		top: px2vw(-43);
	}

	.personal-info img {
		width: px2vw(65);
		height: px2vw(65);
		display: block;
		border-radius: 50%;
		margin: 0 auto;
	}

	.personal-info p {
		font-size: px2vw(17);
		font-weight: bold;
		text-align: center;
	}

	.personal-cla {
		display: flex;
		display: -webkit-flex;
		justify-content: space-between;
		padding-top: px2vw(90);
		padding-left: px2vw(25);
		padding-right: px2vw(25);

		box-sizing: border-box;
	}

	.personal-cla-con {
		width: px2vw(114);
		height: px2vw(35);
		border: 1px solid #53BBB3;
		border-radius: px2vw(35);
		display: flex;
		display: -webkit-flex;
		align-items: center;
		justify-content: center;
	}

	.personal-cla-con p {
		font-size: px2vw(12);
		color: #53BBB3;
		margin-left: px2vw(8);
	}
</style>
